package com.cola.BigNumber;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;

/**
 * @Grup:com.cola.BigNumberDemo
 * @Auther:cola
 * @Data:2021/3/16-2021-03-23:07
 * @version:1.0
 */
public class Test {
    public static void main(String[] args) {
        //大整数运算
        String val1="9454879546478749879876846";
        String val2="4776465498796163498764165";
        BigInteger b1=new BigInteger(val1);
        BigInteger b2=new BigInteger(val2);
        System.out.println(b1.add(b2));//+
        System.out.println(b1.subtract(b2));//-
        System.out.println(b1.multiply(b2));//*
        System.out.println(b1.divide(b2));// /
        System.out.println(b1.remainder(b2));// %
        System.out.println(Arrays.toString(b1.divideAndRemainder(b2)));//  /and%

        String val3="4548.87986654987983654687985646";
        String val4="449.8654987654654687646798746878";
        BigDecimal b3=new BigDecimal(val3);
        BigDecimal b4=new BigDecimal(val4);
        System.out.println(b3.add(b4));
        System.out.println(b3.subtract(b4));
        System.out.println(b3.multiply(b4));
        System.out.println(b3.divide(b4, 5));
    }
}
